package com.j2ee.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;

/**
 * @author JiangQikun
 * @date 2024/6/1 1:48
 */

@WebServlet("/saveSession")
public class SaveSessionServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        // 创建 Session
        final HttpSession session = req.getSession();
        // 存储数据
        session.setAttribute("msg","hello session");

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
